<?php
namespace app\common\logic;
use think\facade\Db;
/**
 * 数据库操作类
 */
class Dbbase
{
    /**
     * 增加字段
     */
    public function addField($table,$field,$type='decimal(12,2)',$default='0.00'){
        if($table!='' && $field!=''){
            $fields = Db::name($table)->getTableFields();
            if(!in_array($field,$fields)){
                $sql = "alter table `sy_".$table."` add `".$field."` ".$type." default '".$default."'";
                Db::execute($sql);
            }
        }
    }

    /**
     * 检测字段
     */
    public function checkField($table,$field){
        if($table!='' && $field!=''){
            $fields = Db::name($table)->getTableFields();
            if(in_array($field,$fields)){
                return true;
            }
        }
        return false;
    }
}